#pragma once
#include"rbtree.h"


namespace bit
{
	template<class K>
	class set
	{
		struct setkeyoft
		{
			const K& operator ()(const K& key)
			{
				return key;
			}
		};
	public:
		typedef typename rbTree<K,const K, setkeyoft> ::Iterator iterator;
		typedef typename rbTree<K,const K, setkeyoft> ::const_Iterator const_iterator;

		iterator begin()
		{
			return _t.Begin();
		}
		iterator end()
		{
			return _t.End();
		}

		const_iterator begin() const
		{
			return _t.Begin();
		}
		const_iterator end()  const
		{
			return _t.End();
		}

		iterator find(const K & key)
		{
			return _t.find(key);
		}
		pair<iterator, bool> insert(const K& key)
		{
			return _t.insert(key);
		}
	private:
		rbTree<K, const K, setkeyoft> _t;
	};

	void print(const set<int> & s)
	{
		set<int>::const_iterator it = s.begin();
		while (it!= s.end())
		{
			
			cout << *it << " ";
			++it;
		}
		cout << endl;
	}

	void testset()
	{
		set<int> t;
		int a[] = { 16,3,7,11,9,26,18,14,15 };
		int b[] = { 4,2,6,1,3,5,15,7,16,14 };
		for (auto e : b)
		{
			t.insert(e);
		}

		for (auto e : t)
		{
			cout << e << " ";
		}
		cout << endl;

		set<int>::iterator it = t.find(6);

		while(it != t.begin())
		{
			--it;
			cout << *it<<"   ";
			//*it = 0;
		}
		cout << endl;
		
	}
}

